import { type DefineComponent } from 'vue';
import { Recordable } from '../../f-table';

export type IForm = DefineComponent<
  {},
  {},
  {},
  {},
  {
    init: (...args: any[]) => void;
    submit: () => Promise<boolean>;
  }
>;

export const components: Recordable<IForm> = {};
export const componentNames: string[] = [];

const modules = import.meta.glob('./components/**/*.vue', { eager: true });
// 动态导入并注册所有组件
Object.keys(modules).forEach((path) => {
  const module = modules[path] as any;
  
  
  const name = path.split('/').pop()?.split('.')[0] as string;
  console.log(name);

  
  componentNames.push(name);
  components[name] = module.default as IForm;
});

console.log(componentNames, components);
